﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TileDemo.View
{
    class LevelView
    {

        public TextureAssets m_textures = new TextureAssets();
        

        
        
        public int m_variation = TextureAssets.CleanTiles;

        public void DrawLevel(Model.Level a_level, ref SpriteBatch a_batch)
        {
            float scale = 64;

            for (int x = 0; x < Model.Level.WIDTH; x++)
            {
                for (int y = 0; y < Model.Level.HEIGHT; y++)
                {
                    Rectangle destination = new Rectangle((int)(x * scale), (int)(y * scale), (int)scale, (int)scale);
                        
                    float rotation =0;
                    Rectangle sourceUV = TextureAssets.GetTileSourceRectAndRotation(x, y, a_level, out rotation, m_variation);
                    
                    a_batch.Draw(m_textures.m_tiles, destination, sourceUV, Color.White, rotation, new Vector2(TextureAssets.g_tileSize / 2), SpriteEffects.None, 0.0f);
                    
                }

            }
        }

        
    }
}
